<%@ page import="java.sql.ResultSet" %>
<%@ page import="com.wy.util.DBUtil" %>
<%@ page import="com.wy.util.MD5Util" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Date" %><%--
  Created by IntelliJ IDEA.
  User: 13939
  Date: 2024/11/29
  Time: 9:32
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%
    Integer uid = (Integer) session.getAttribute("uid");
    Date now = new Date();
    String newsTitle = request.getParameter("newsTitle");
    String newsContent = request.getParameter("newsContent");
    String newsCategory = request.getParameter("newsCategory");
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    String formattedDate = sdf.format(now);
    String sql = "INSERT INTO news_headline (title, article, type, publisher, page_views, create_time, update_time, is_deleted) " +
            "VALUES ('" + newsTitle + "', '" + newsContent + "', '" + newsCategory + "', '" + uid + "', " + 0 + ", '" + formattedDate + "', '" + formattedDate + "', " + 0 + ");";
    DBUtil dbUtil = new DBUtil();
    int n = dbUtil.update(sql);
    if (n > 0) {
        response.sendRedirect("newSuccess.jsp");
    } else {
        out.print("增加失败!");
    }%>
